const express = require('express')
const app = express()
const hostname = '127.0.0.1'
const port = 3001

const data = [
    {
        name:'zhangsan',
        age:88,
        sex:'female'
    },
    {
        name:'lisi',
        age:25,
        sex:'man'
    },
    {
        name:'wangwu',
        age:33,
        sex:'female'
    }
]

app.use((req,res,next) => {
    console.log(`收到请求${req.url}`);
    next()
})

app.get('/student',(req,res)=>{
     res.send(JSON.stringify(data))
})


app.listen(port,hostname,()=>{
    console.log("服务已启动，访问student数据："+"http://"+hostname+":"+port+"/student");
})